package com.school.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.school.pojo.Spos;
import com.school.pojo.Tpos;
import com.school.service.SposService;
import com.school.util.Result;
import com.school.util.Tool;

@RequestMapping("/spos")
@RestController
public class SposController implements Tool<Spos>{
	
	@Autowired
	private SposService sposService;
	
	@Override
	@RequestMapping("/findAll")
	public Result<Spos> findAll(int page, int pageSize, Spos t) {
		
		List<Spos> list= sposService.findAll(t,page,pageSize);
		PageInfo<Spos> info=new PageInfo<>(list);
		Result<Spos> result=new Result<Spos>();
		result.setList(info.getList());
		result.setCount(info.getTotal());
		return result;
	}

	@Override
	@RequestMapping("/findById")
	public Result<Spos> findbyId(int id) {
		Spos spos=sposService.findbyId(id);
		Result<Spos> result=new Result<>();
		result.setData(spos);
		return result;
		
	}

	@Override
	@RequestMapping("/add")
	public int add(Spos t) {
		int row=sposService.add(t);
		return row;
	}

	@Override
	@RequestMapping("/edit")
	public int edit(Spos t) {
		
		return sposService.edit(t);
	}

	@Override
	public int del(int id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	@RequestMapping("delbatch")
	public int delbatch(int[] id) {
		
		return sposService.delbatch(id);
	}

	
	
}
